using System;

namespace ZFramework.Runtime
{
    public abstract class ObjectPoolBase
    {
        private readonly string _name;

        public ObjectPoolBase(string name)
        {
            _name = name;
        }

        public string Name => _name;
        
        /// <summary>
        /// 获取对象池中对象的数量。
        /// </summary>
        public abstract int Count
        {
            get;
        }
        
        /// <summary>
        /// 获取对象池中能被释放的对象的数量。
        /// </summary>
        public abstract int CanReleaseCount
        {
            get;
        }

        /// <summary>
        /// 获取是否允许对象被多次获取。
        /// </summary>
        public abstract bool AllowMultiSpawn
        {
            get;
        }
        
        /// <summary>
        /// 获取或设置对象池自动释放可释放对象的间隔秒数。
        /// </summary>
        public abstract float AutoReleaseInterval
        {
            get;
            set;
        }

        /// <summary>
        /// 获取或设置对象池的容量。
        /// </summary>
        public abstract int Capacity
        {
            get;
            set;
        }

        /// <summary>
        /// 获取或设置对象池对象过期秒数。
        /// </summary>
        public abstract float ExpireTime
        {
            get;
            set;
        }
        
        /// <summary>
        /// 获取或设置对象池的优先级。
        /// </summary>
        public abstract int Priority
        {
            get;
            set;
        }
        
        /// <summary>
        /// 获取对象池完整名称。
        /// </summary>
        public string FullName
        {
            get
            {
                return new TypeNamePair(ObjectType, _name).ToString();
            }
        }
        
        /// <summary>
        /// 获取对象池对象类型。
        /// </summary>
        public abstract Type ObjectType
        {
            get;
        }

        public abstract void Update();
        
        public abstract void ReleaseAllUnused();

        public abstract ObjectInfo[] GetAllObjectInfos();

        public abstract void Release();
    }
}